<?PHP
session_start();
include_once "ini.php";
$id_cam = $_POST['id_cam'];

dbconnect();
$sql = "SELECT * FROM users WHERE id_user = '".$_SESSION['id_user']."';";
$requete = mysql_query($sql);
if (!$requete)
{
    echo "SQL error : ", $sql;
    exit ;
}
else
{
    $tab = mysql_fetch_assoc($requete);
    $favoris = $tab['favoris'];
    $favoris .= ":".$id_cam;
    $query = "UPDATE `users` SET `favoris` = '".$favoris."' WHERE `users`.`id_user` = '".$_SESSION['id_user']."' LIMIT 1 ;";
    $result = mysql_query($query);
    if (!$result)
    {
        echo "SQL error : ", $query;
        exit ;
    }
    else
    {
        echo "Add favoris done.";
    }
}
dbclose();
?>
